package com.dianban.controller;

import com.dianban.base.ResultCode;
import com.dianban.base.ResultVo;
import com.dianban.entity.FacePayConfig;
import com.dianban.service.FacePayConfigService;
import com.dianban.service.FacePayDeviceLogService;
import com.dianban.service.ShopUserService;
import com.dianban.service.ShoproOrderService;
import com.dianban.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;


@Api(value = "ApiFacePayDeviceLogController", description = "设备控制器")
@RestController
@RequestMapping(value = "${interfacePath}/facePayDevice/")
public class ApiFacePayDeviceLogController extends BaseController {
    private Logger logger = LoggerFactory.getLogger(ApiFacePayDeviceLogController.class);

    @Autowired
    private FacePayDeviceLogService facePayDeviceLogService;

    @ApiOperation(notes = "deviceSwitch", httpMethod = "GET", value = "设备开关")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "executeMinute", value = "执行分钟", required = true, paramType = "query", dataType = "string"),
    })
    @RequestMapping(value = "deviceSwitch", method = RequestMethod.GET)
    public ResultVo deviceSwitch(Integer executeMinute,HttpServletRequest request, HttpServletResponse response) {
        if(executeMinute == null){
            return ResultVo.error(ResultCode.ERROR, "执行分钟不能为空");
        }
        logger.info("设备开关,开始");
        try {
            // 调用开关
            facePayDeviceLogService.deviceSwitch(0, null, executeMinute);
        } catch (Throwable e) {
            logger.error("设备开关,异常:{}", e.getMessage());
            e.printStackTrace();
        }
        logger.info("设备开关,完成");
        return ResultVo.success("", "操作成功");
    }

}
